import { parse } from 'querystring';

// setTimeout promise版
export const sleep = (time: number) =>
  new Promise<void>((resolve) => {
    if (time) {
      setTimeout(resolve, time);
    } else {
      resolve();
    }
  });

// 获取query参数
export const getPageQuery = () => {
  return parse(window?.location?.search?.split('?')[1]);
};

// 判断是否是空数组
export function isEmptyArray(arr: any) {
  return !Array.isArray(arr) || arr?.length === 0;
}
